Skip to content

fix: clear error when model file is missing or malformed (closes #20) - #83

Open
manishpaulish wants to merge 1 commit into
wcwitt:mainfrom
manishpaulish:fix/model-file-error-handling
Open

fix: clear error when model file is missing or malformed (closes #20)#83
manishpaulish wants to merge 1 commit into
wcwitt:mainfrom
manishpaulish:fix/model-file-error-handling

Conversation

@manishpaulish

Copy link
Copy Markdown

Fixes #20.

Loading a missing or malformed model file previously ran nlohmann::json::parse on a failed/unopened stream, producing a confusing crash rather than a useful message:

Loading MACEKokkos model from '.../model.json' ... malloc_consolidate(): invalid chunk size

This adds two checks in load_from_json (in both mace.cpp and mace_kokkos.cpp):

  • if the file cannot be opened, throw Could not open model file: <path>
  • if parsing fails, throw Failed to parse model file '<path>': <detail>

Verified on macOS: loading a nonexistent path now throws Could not open model file: /tmp/does_not_exist.json instead of crashing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Confusing error when model not found

1 participant